<!DOCTYPE html>

<html>
    <head>
        <meta charset="UTF-8">
        <title>编辑学生</title>
        <link rel="stylesheet" href="/stylesheets/bootstrap.css">
    </head>
    <body>

    <form action="/student/edit" method="post">
        <input type="hidden" name="id" value="{{stu.id}}" >
        <table class="table">
            <tr>
                <td>姓名</td>
                <td>
                    <input type="text" name="name" value="{{stu.name}}">
                </td>
            </tr>
            <tr>
                <td>年龄</td>
                <td> <input type="text" name="age" value="{{stu.age}}"> </td>
            </tr>
            <tr>
                <td>班级</td>
                <td>
                    <select name="classId">
                        {% for c in classes %}
                        <option value="{{c.id}}" {{ 'selected' if c.id == stu.cid else ''}}>{{c.name}}</option>
                        {% endfor %}
                    </select>
                </td>
            </tr>
            <tr>
                <td>性别</td>
                <td>
                    <input type="radio" name="gender" value="male" {{ 'checked' if stu.gender == 'male' else ''}}>男
                    <input type="radio" name="gender" value="female" {{ 'checked' if stu.gender == 'female' else ''}}>女
                </td>
            </tr>
            <tr>
                <td>爱好</td>
                <td>
                    <input type="checkbox" name="hobby" value="篮球" {{ 'checked' if stu.hobbies.includes('篮球') else ''}}>篮球
                    <input type="checkbox" name="hobby" value="足球" {{ 'checked' if stu.hobbies.includes('足球') else ''}}>足球
                    <input type="checkbox" name="hobby" value="网球" {{ 'checked' if stu.hobbies.includes('网球') else ''}}>网球
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <button type="submit" class="btn btn-primary">修改学生</button>
                    <a href="/student/list" class="btn btn-primary">查看学生信息</a>
                </td>
            </tr>
        </table>
    </form>
    </body>
</html>